***** RUN DO_MASTER.do ***** do "$Do_files\DO_MASTER.do"

global program "OA_TableB36"
cap log close
cap log using "$Log_files\log_$program$today", replace

**** REPLICATION OF TABLE B.3.6 ****

clear all
set mem 2g
set more off

// Import data

use $Data\data_news_voting, clear

// Get controls

global ctrl_base	"sh_lde lpop_A sh_F sh_F_new sh_cspsup sh_sec sh_ter lmean_reink lmean_reink2 charact_altitude charact_altitude_std sh_active sh_young sh_prot sh_M com_property"
global ctrl_plus	"mean_votation lcrSR_F_N"
global fe			"charact_agglo"
global fe_iv		"I_charact_agglo_*"
global cluster		"charact_agglo"

// Regressions

g instr_dev_mk0=instr_dev_mk // Baseline
g sample_hq00dstr0=sample_hq00dstr // Baseline
g mk0=mk // Baseline

foreach newspaper in 0 1 2 3 4{
	
	cap drop instr_dev_mk
	cap g instr_dev_mk=instr_dev_mk`newspaper'
	reghdfe oui instr_dev_mk /// 		
		$ctrl_plus ///
		$ctrl_base mk`newspaper' ///
		if sample_hq00dstr`newspaper'==1, ///
		absorb($fe) cluster($cluster) keepsing
	estimates store RF_dev_ctrl`newspaper'

}

// Labels

la var instr_dev_mk 	"HQ $ \mathtt{CPD} $ Deviation ($ \mathtt{\Delta HQC} $)"
la var lcrSR_F_N 		"[0.1em] Local $ \mathtt{CPD} $"
la var mean_votation 	"[0.1em] Past Vote Outcomes"

// Table for Paper

estout RF_dev_ctrl0 RF_dev_ctrl1 RF_dev_ctrl2 RF_dev_ctrl3 RF_dev_ctrl4 ///
	using "$Results\\$program.tex", replace style(tex) type label	///
	cells(b(star fmt(%9.3f)) se(par fmt(%9.3f)))  ///
	stats(N r2_a, lab("Observations" "Adjusted $ R^2 $") fmt(0 3)) /// 
	collabels(none) ///
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels($^c$ .1 $^b$ .05 $^a$ .01) ///
	keep(instr_dev_mk mean_votation lcrSR_F_N) /// 
	order(instr_dev_mk lcrSR_F_N mean_votation) ///	
	title(News and voting: Reduced-form estimates when adding newspapers) ///	
	prehead("\begin{table}[!h]" ///
	"\begin{center}" ///
	"\begin{threeparttable}" ///
	"\begin{footnotesize}" ///
	"\caption{\small{@title}\label{$program}}" ///
	"\begin{tabular*}{\columnwidth}{@{\extracolsep{\stretch{1}}}l*{@M}{c}@{}}" ///
	"\hline" "\hline" ///	
	"\\" ///
	"Specification 			&\multicolumn{5}{c}{Reduced-Form Estimation} 			\\" ///
	"						\cmidrule(lr){2-6} " ///
	"Dependent Variable 	&\multicolumn{5}{c}{Minaret Ban approval (\%Yes)} \\" ///
	"						\cmidrule(lr){2-6}" ///
	"Newspaper added 		&\multicolumn{1}{c}{Baseline}	&\multicolumn{1}{c}{Blick} 		&\multicolumn{1}{c}{Mittelland} 		&\multicolumn{1}{c}{N. Luzerner}				&\multicolumn{1}{c}{Sudost-} \\" ///
	"						&\multicolumn{1}{c}{sample}		&\multicolumn{1}{c}{} 			&\multicolumn{1}{c}{Zeitung} 			&\multicolumn{1}{c}{Zeitung}					&\multicolumn{1}{c}{schweiz}\\" ///
	"						\cmidrule(lr){2-2}			\cmidrule(lr){3-3}				\cmidrule(lr){4-4}						\cmidrule(lr){5-5}								\cmidrule(lr){6-6}		" /// 
	"						&\multicolumn{1}{c}{(1)} 	&\multicolumn{1}{c}{(2)}  		&\multicolumn{1}{c}{(3)} 				&\multicolumn{1}{c}{(4)}  						&\multicolumn{1}{c}{(5)}\\") ///
	posthead("\hline" ///
	"\\") ///
	prefoot("\\" ///
	"\hline") ///
	postfoot("\hline" "\hline" ///
	"\end{tabular*}" /// 
	"\end{footnotesize}" ///
	"\begin{tablenotes}[normal,flushleft]" ///
	"\begin{scriptsize}" ///
	"\item \emph{Notes}:" /// 
	"The unit of observation is a municipality. " ///
	"Standard errors clustered at agglomeration level in parentheses. " ///
	"{$^c$} significant at 10\%; {$^b$} significant at 5\%; {$^a$} significant at 1\%. " ///
	"Columns (1) presents the baseline reduced-form estimation. " ///
	"Columns (2) to (5) display reduced-form estimates when adding the 4 largest newspapers that are not in our baseline dataset. " ///
	"All regressions include the full vector of controls of Table \ref{Main_Table2}. " ///
	"" ///
	"\end{scriptsize}" ///
	"\end{tablenotes}" ///
	"\end{threeparttable}" ///
	"\end{center}" ///
	"\end{table}")

cap log close
